import 'package:flutter/material.dart';
///demo入口页
class Demo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return DemoState();
  }
}

class DemoState extends State<Demo> {
  final List<Map<String, String>> _links = [
    {"text": "布局类Widget"},
    {"demo1": "Column布局交叉轴方向测试"},
    {"demo2": "流式布局（Wrao跟Flow）"},
    {"demo3": "堆叠布局（Stack容器跟Positioned子组件）"},
    {"text": "容器类Widget"},
    {"demo4": "DecoratedBox"},
    {"demo5": "Transform变换"},
    {"text": "可滚动Widget"},
    {"demo6": "ScrollView"},
    {"demo7": "GridView"},
    {"demo8": "ScrollController"},
    {"text": "功能型Widget"},
    {"demo9": "InheritedWidget"},
    {"text": "动画"},
    {"demo10": "动画简介"},
  ];
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('demo入口页'),
      ),
      floatingActionButton: FloatingActionButton(
        child: new Icon(Icons.add),
      ),
      // // FloatingActionButtonLocation结合BottomAppBar实现底部导航并嵌入一个按钮在中间，
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
      bottomNavigationBar: BottomAppBar(
        color: Colors.white,
        shape: CircularNotchedRectangle(), // 底部导航栏打一个圆形的洞
        child: Row(
          children: [
            IconButton(icon: Icon(Icons.home)),
            SizedBox(), //中间位置空出
            IconButton(icon: Icon(Icons.business)),
          ],
          mainAxisAlignment: MainAxisAlignment.spaceAround, //均分底部导航栏横向空间
        ),
      ),
      body: new ListView(
        children: _links.map((item) {
          Widget widget;
          item.forEach((k, v) {
            if(k == 'text'){
              widget = new Padding(
                padding: EdgeInsets.all(16.0),
                child: new Text(v + '：'),
              );
            }
            else{
              widget = new Padding(
                padding: EdgeInsets.only(left: 16.0),
                child: new RaisedButton(
                  color: Theme.of(context).primaryColor,
                  textColor: Colors.white,
                  child: new Text(v),
                  onPressed: () {
                    Navigator.of(context).pushNamed(k);
                  },
                ),
              );
            }
          });
          return new Row(
            children: <Widget>[widget],
          );
        }).toList(),
      ),
    );
  }
}